li = []  # 存储对象


class Bank:
    """银行类 父类"""

    def __init__(self, name, card_number, pwd, balance):
        self.name = name
        self.card_number = card_number
        self.pwd = pwd
        self.balance = balance
        # 添加对象
        li.append(self)

    # 取款
    def withdrawal(self):
        money = int(input('请输入要取款的金额：'))
        if self.balance >= money:
            self.balance -= money
            print(f'取款成功！账号的余额{self.balance}')
        else:
            print('余额不足')


class LocalBank(Bank):  # 继承
    # 转账
    def transfer_accounts(self):
        card = int(input('请输入要转账的卡号：'))
        for i in li:
            # 判断卡号是否存在
            if card == i.card_number and card != self.card_number:
                # 判断卡内余额
                money = float(input('请输入要转账的金额：'))
                if self.balance >= money:
                    self.balance -= money
                    i.balance += money
                    print(f'转账成功！当前卡内余额：{self.balance}')
                    print(f'卡号：{card}成功接收一笔{money}元金额！当前卡内余额{i.balance}')
                    break
        else:
            print('卡号不存在或者输入有误')


class OtherBank(Bank):
    # 取款
    def withdrawal(self):
        print('本银行卡在进行取款操作，需要加收两元服务费用')
        money = int(input('请输入要取款的金额：'))
        if self.balance >= money + 2:
            self.balance -= money + 2
            print(f'取款成功！账号的余额{self.balance}')
        else:
            print('余额不足')


# 创建银行类对象：
b1 = Bank('张三', 10001, 123456, 1000)
# 取款
b1.withdrawal()

# 创建本银行卡类对象：
b2 = LocalBank('李四', 20001, 123456, 10000)
b3 = LocalBank('王五', 20002, 123456, 100)
# 取款
b2.withdrawal()
# 转账
b2.transfer_accounts()

# 创建其他银行卡类对象：
b6 = OtherBank('赵六', 30001, 123456, 20000)
# 取款
b6.withdrawal()